{{include file="header.html"}}
	<div class="header loginhead">
		<div class="nav">
			 <div class="search return"><a href="javascript:history.go(-1);"></a></div>
		    <div class="title">结算</div>
		    <div id="screenIfmNav" class="screenIfm" onclick="$('#sub-title').toggle();$(this).hide();"></div>
		</div>
	</div>
	<div class="container">
		<div class="tabbox paylist">
			<div class="tabmain max" style="display: block;">
				<ul>
					{{if $result}}
					{{foreach item=val from=$result}}
					<li>
						<div class="deps" orderid="{{$val.orderid}}">
							<img src="{{$val.image|photo}}" alt="">
							<p>(第{{$val.id}}{{$val.goods_id}}云){{$val.goodsname}}</p>
							<div class="num"><span price="{{($val.number*1)*($val.price*1)}}">{{$val.number}}</span>人次</div>
						</div>
					</li>
					{{/foreach}}
					{{/if}}
				</ul>
			</div>
			<div class="ud slide">
				<span><img src="{{$smarty.const.__APP__}}images/down.png" alt=""><i>展开</i><i style="display:none;">收起</i></span>
			</div>
			<div class="total"><span>共0件商品</span><span>合计：<i class="price">￥0.00</i></span></div>
			<script type="text/javascript">
				$(function(){
					$('.ud').click(function(){
						$('.ud img').toggleClass('rotate');
						$('.ud i').toggle();
						$('.ud').toggleClass('slide');
						$('.tabmain').toggleClass('max');
					})
				})
			</script>
		</div>
		<!-- <div class="paytype r_pay">
			<ul>
				<li class="r_disabled">
					<div class="checkbox">
						<input type="radio" name="payway" value="1" id="ty1">
						<label for="ty1"></label>
					</div>
					<p>福分支付<span>(您的福分20)</span></p>
					<label for="ty1"></label>
				</li>
				<li class="r_disabled">
					
					<div class="checkbox">
						<input type="radio" name="payway" value="1" id="ty2">
						<label for="ty2"></label>
					</div>
					<p>余额支付<span>(账户余额￥0.00)</span></p>
					<label for="ty2"></label>
				</li>
			</ul>
		</div> -->
		<div class="paytype r_pay" style="margin-bottom:2rem;">
			<ul>
				<li>
					
					<div class="checkbox">
						<p>需支付：<i class="price">￥0.00</i></p>
					</div>
					<p>网银支付</p>
				</li>
				<li>
					<div class="checkbox">
						<input type="radio" name="payway" value="2" id="ty3">
						<label for="ty3"></label>
					</div>
					<img src="{{$smarty.const.__APP__}}images/icon_pay_wangyin.png" alt="">
					<div class="clear"></div>
					<label for="ty3"></label>
				</li>
<!-- 				<li>
					
					<div class="checkbox">
						<input type="radio" name="payway" value="0" id="ty4">
						<label for="ty4"></label>
					</div>
					<img src="{{$smarty.const.__APP__}}images/icon_pay_unionpay.png" alt="">
					<div class="clear"></div>
					<label for="ty4"></label>
				</li> -->
				<li>
					
					<div class="checkbox">
						<input type="radio" name="payway" value="1" id="ty5">
						<label for="ty5"></label>
					</div>
					<img src="{{$smarty.const.__APP__}}images/icon_pay_weixin.png" alt="">
					<div class="clear"></div>
					<label for="ty5"></label>
				</li>
			</ul>
		</div>
		<script type="text/javascript">
			$(function(){
				$('.paytype li').each(function(){
					if($(this).hasClass('r_disabled')){
						$(this).find('input').attr('disabled',true);
					}
				})
			})
		</script>
		<div class="paybtn">
			<a href="javascript:">
				去支付
			</a>
		</div>
	</div>
	 <form style="display:none" method='post' action='https://pay.paysapi.com'>
	 	<input name="buy_type" type="text" value="lot">
	 	<input name="goodsid" type="text" value="{{$smarty.get.goodsid}}">
	 	<input name="total" type="text" value="{{$smarty.get.total}}">
    	<input name='price' id='price' type='text' value=''/>
        <input name='price_real' type='text' value='{{$result.price}}'/>
        <input name='price_str' type='text' value=''/>
        <input name='rate' type='text' value='{{$result.rate}}'/>
		<input name='istype' id='istype' type='text' value='1'/>
        <input name='goodsname' id='goodsname' type='text' value='批量购买'/>
        <input name='address_id'  type='text' value='{{$address_id}}'/>
        <input name='key' id='key' type='text' />
        <input name='notify_url' id='notify_url' type='text' />
        <input name='orderid' id='orderid' type='text' />
        <input name='orderids' id='orderids' type='text' />
        <input name='orderuid' id='orderuid' type='text' />
        <input name='return_url' id='return_url' type='text' />
        <input name='uid' id='uid' type='text' />
        <input type="text" name="number" id="number" value="1">
        <input type="text" name="image" id="image" value="{{$result.image}}">
        <input type="text" name="partake" id="partake" value="{{$result.number - $count.count}}">
        <input type='submit' id='submitdemo1'>
    </form>
	<script type="text/javascript">

	var number = $('.tabmain ul li').length;
	$('.total span:first').text("共"+number+"件商品");
	var price = '';
	$(".num span").each(function(){
		price = (price*1)+($(this).attr('price')*1);
	})
	$('.price').text("￥"+price+".00");
	
	function getorder(){
		var orderids = "";
		var price = "";
		//订单号
		$(".deps").each(function(){
			orderids += (","+$(this).attr('orderid'));
		})
		$("#orderids").val(orderids.substr(1));
		//金额
		$(".num span").each(function(){
			price += (","+($(this).attr('price')*1));
		})
		$("input[name='price_str']").val(price.substr(1));

	}

	$(".paybtn a").click(function(){
		var val = $("input[name='payway']:checked").val();
		$("#price").val(price);
		$("#istype").val(val);
		if(!val){
			ui.alert('请选择付款方式！');
			return false;
		}
		getorder();
		var from = $("form").serialize();
		$.post('{{"index.php?app=Goods&act=pays"|URL}}',from,function(data){
			if (data.statusCode == '200'){
                $("#goodsname").val(data.message.goodsname);
                $("#istype").val(data.message.istype);
                $("#key").val(data.message.key);
                $("#notify_url").val(data.message.notify_url);
                $("#orderid").val(data.message.orderid);
                $("#orderuid").val(data.message.orderuid);
                $("#price").val(data.message.price);
                $("#return_url").val(data.message.return_url);
                $("#uid").val(data.message.uid);
                $('#submitdemo1').click();
            }else if(data.statusCode == '201'){
            	ui.alert(data.message);
                $.cookie('history_url', window.location.href, {expires: null,path: "/"});
            	setTimeout(function(){
					location.href='{{"index.php?app=Login"|URL}}';
				},1000);
            }else if(data.statusCode == '202'){
                ui.alert(data.message);
                $.cookie('history_url', window.location.href, {expires: null,path: "/"});
                setTimeout(function(){
                    location.href='{{"index.php?app=address&act=modify"|URL}}';
                },1000);
            }else{
                ui.error(data.message);
            }
		},"json");
	})
	</script>
{{include file="footer.html"}}